<!-- photolist 组件 -->
<template>
  <div class="photo-container">
    <!-- 顶部滑动条 -->
    <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a :class="['mui-control-item', item.id===0?'mui-active':'']" href="#item1mobile" data-wid="tab-top-subpage-1.html" v-for="item in categoryList" :key="item.id" @click="getImgList(item.id)">
							{{ item.title }}
						</a>
					</div>
				</div>
		</div>
		<!-- 图片列表 -->
		<ul class="img-list">
			<router-link  :to="'/home/photoinfo/'+item.id" v-for="item in imgList" :key="item.id" tag="li">
				<img v-lazy="item.img_url">
				<div class="describe">
					<h1 class="des-title" v-text="item.title"></h1>
					<div class="des-content" v-text="item.zhaiyao"></div>
				</div>
			</router-link>
		</ul>
  </div>
</template>

<script>
  // 1、导入mui js文件
  import mui from '../../../public/lib/mui/js/mui.js'
  // const mui = require('../../../public/lib/mui/js/mui.js')
  // 2、初始化滑动控件
   
  export default {
    data() {
      return {
				categoryList: [], // 图片分类
				imgList: [] // 图片列表
      }
    },
  
    created() {
			this.getImgCategory()
			this.getImgList(0)
		},
    mounted () {
     mui('.mui-scroll-wrapper').scroll({
	      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
      });
    },
    methods: {
			getImgCategory() { // 获取图片分类
				this.axios.get('api/getimgcategory')
        .then( resp => {
          if (resp.data.status ===0) { // 获取数据成功
						this.categoryList = resp.data.message;
						this.categoryList.unshift({ title: '全部', id: 0})
          }else { // 获取失败
						Toast('获取数据失败')
          }
				})
			},
			getImgList(id) { // 获取图片列表
				this.axios.get('api/getimages/' + id)
        .then( resp => {
          if (resp.data.status ===0) { // 获取数据成功
						this.imgList = resp.data.message;
          }else { // 获取失败
            Toast('获取数据失败')
          }
				})
			}
			
		},
		components: {}
	}	
</script>

<style lang='scss' scoped>
  * { touch-action: pan-x;}
	.photo-container {
		.img-list {
			list-style: none;
			margin: 0;
			padding: 10px;
			padding-bottom: 0;
			li {
				background-color: #ccc;
				position: relative;
				text-align: center;
				margin-bottom: 10px;
				box-shadow: 0 0 9px #999;
				img {
					width: 100%;
					vertical-align: middle;
				}
				img[lazy="loading"] {
				width: 40px;
				height: 300px;
				margin: auto;
				}
				.describe {
					max-height: 84px;
					color: #fff;
					position: absolute;
					background-color: rgba(0, 0, 0, 0.4);
					bottom: 0;
					text-align: left;
					.des-title {
						font-size: 14px;
					}
					.des-content {
						font-size: 12px;
					}
				}
			}
			
		}
	}
</style>